export default class Http {
	 // baseUrl = "http://192.168.1.238:8080/"
	 baseUrl = "https://api.ousukeji.com/"
	async get(url) {
		let res = await this._request(url, "GET", {});
		console.log("网络请求", res);
		return res;
	}
async post(url,data) {
		let res = await this._request(url, "POST", data);
		
		console.log("网络请求", res);
		return res;
	}
	



async _request(url,method,data){
	var header = {
				"content-type": "application/json"
			};
			var token = uni.getStorageSync('token'); // 从本地缓存读取tokenName值
			header['satoken'] = token
	return new Promise((resolve, reject) => {
		uni.request({
			url: this.baseUrl+url, // 仅为示例，并非真实接口地址。
			header: header,
			method: method,
			data: data,
			success: (res) => {
				console.log(res.data);
				if(res.data.status&&res.data.status==500){
					return uni.redirectTo({
						url:"/pages/login/login"
					})
				}
				resolve(res)
			},
			fail: fail => {
				reject(res)
			}
		})
	})
}


	
}